<html>
<head>
<style>
  .ace_editor {
    border: 0;
    width: auto;
    height: 100%;
    margin: 0;
    top:0;
    right:0;
    bottom:0;
    left:0;
    z-index: 10000;
    touch-action: none;
  }

  body {
    padding: 0px;
    margin: 0px;
    overflow: hidden;
    -ms-overflow-style: scrollbar;
  }
</style>
</head>
<body>
<textarea id="source">package com.sencha.gxt.explorer.client.animation;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Overflow;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.core.client.Style.Direction;
import com.sencha.gxt.core.client.util.Rectangle;
import com.sencha.gxt.explorer.client.app.ui.ExampleContainer;
import com.sencha.gxt.explorer.client.model.Example.Detail;
import com.sencha.gxt.fx.client.FxElement;
import com.sencha.gxt.fx.client.animation.AfterAnimateEvent;
import com.sencha.gxt.fx.client.animation.AfterAnimateEvent.AfterAnimateHandler;
import com.sencha.gxt.fx.client.animation.Fx;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.event.SelectEvent;

public class AnimationUiBinderExample implements IsWidget, EntryPoint {

  interface MyUiBinder extends UiBinder<Widget, AnimationUiBinderExample> {
  }

  protected static final int PREFERRED_HEIGHT = 320;
  protected static final int PREFERRED_WIDTH = 435;

  private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);

  @UiField
  ContentPanel cp;
  @UiField
  TextButton move;
  @UiField
  TextButton blink;
  @UiField
  TextButton event;

  private Widget widget;

  @Override
  public Widget asWidget() {
    if (widget == null) {
      widget = uiBinder.createAndBindUi(this);
      widget.getElement().getStyle().setOverflow(Overflow.VISIBLE);
    }

    return widget;
  }

  @UiHandler("slide")
  public void onSlide(SelectEvent event) {
    if (cp.isVisible()) {
      cp.getElement().<FxElement> cast().slideOut(Direction.UP);
      setButtonsEnabled(false);
    } else {
      cp.getElement().<FxElement> cast().slideIn(Direction.DOWN);
      setButtonsEnabled(true);
    }
  }

  @UiHandler("fade")
  public void onFade(SelectEvent event) {
    setButtonsEnabled(!cp.isVisible());
    cp.getElement().<FxElement> cast().fadeToggle();
  }

  @UiHandler("move")
  public void onMove(SelectEvent event) {
    Rectangle bounds = cp.getElement().getBounds();
    cp.getElement().<FxElement> cast().setXY(bounds.getX() + 50, bounds.getY() + 50, new Fx());
  }

  @UiHandler("blink")
  public void onBlink(SelectEvent event) {
    cp.getElement().<FxElement> cast().blink();
  }

  @UiHandler("event")
  public void onEvent(SelectEvent event) {
    Fx fx = new Fx();
    fx.addAfterAnimateHandler(new AfterAnimateHandler() {
      @Override
      public void onAfterAnimate(AfterAnimateEvent event) {
        AlertMessageBox mb = new AlertMessageBox("Animate Event Handler", "AfterAnimateEvent was received...");
        mb.setIcon(AlertMessageBox.ICONS.info());
        mb.show();
      }
    });
    cp.getElement().<FxElement> cast().blink(fx, 50);
  }

  @UiHandler("reset")
  public void onReset(SelectEvent ev) {
    cp.setPosition(115, 70);
    cp.expand();
    cp.getElement().show();
    setButtonsEnabled(true);
  }

  private void setButtonsEnabled(boolean enabled) {
    move.setEnabled(enabled);
    blink.setEnabled(enabled);
    event.setEnabled(enabled);
  }

  @Override
  public void onModuleLoad() {
    new ExampleContainer(this)
        .setPreferredHeight(PREFERRED_HEIGHT)
        .setPreferredWidth(PREFERRED_WIDTH)
        .doStandalone();
  }

}
</textarea>

<script src="../../samples/ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
  var type = "{type}";
  if (type == ("{" + "type}")) {
    // something went wrong, use java as default
    type = "java";
  }
  var editor = ace.edit("source");
  var mode = "ace/mode/" + type;
  var theme = "ace/theme/chrome";
  var readOnly = true;
  editor.getSession().setMode(mode);
  editor.getSession().setUseWorker(false);
  editor.setTheme(theme);
  editor.setShowPrintMargin(false);
  editor.renderer.setShowGutter(true);
  editor.setHighlightActiveLine(false);
  editor.setDisplayIndentGuides(true);
  editor.setReadOnly(readOnly);
  editor.renderer.setPadding(10);
  editor.renderer.setScrollMargin(10, 10, 0, 0);
  editor.getSession().setOptions({
    tabSize: 8,
    useSoftTabs: true,
    useWrapMode: false,
  });
</script>
</body>
</html>